<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浏览器窗体加载事件</title>
</head>

<body>
    <script>
        window.onload = function(e) {
            let btn = window.document.querySelector('#btn');
            btn.addEventListener('click', function(e) {
                window.alert(btn.innerText);
            });
        };
    </script>
    <button id="btn">你过来呀</button>
</body>

</html>